<extend name="Public/base" />

<block name="body">
    <style>
        .add_record div ul li{
            list-style: none;
            margin-top: 30px;
            margin-bottom: 30px;
            margin-left: -50px;
        }
        .add_record div ul li span{
            line-height: 30px;
            width: 70px;
            /*text-align: right;  */
        }
        .add_record div ul li input{
            width: 250px;height: 30px;
            float: right;
            margin-left: 10px;
            border: solid 1px #ccc;
            border-radius: 3px;
            padding-left: 5px;
            line-height: 26px;
        }
        .add_record div ul li select{
            width: 250px;height: 30px;
            float: right;
        }
        .add_record div ul li input:focus {
            border-color: #66afe9;
            outline: 0;
            -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
            box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
        }
        .gray {
            background-color: gray !important;
            border-color: gray !important;
            color: white !important;
        }
        .c_green {
            background-color: #5cb85c !important;
            border-color: #5cb85c !important;
            color: white !important;
        }
        .start {
            background-color: #1E90FF !important;
            border-color: #1E90FF !important;
            color: white !important;
        }

        .c_green:hover {
            background-color: #1da51d !important;
            border-color: #1da51d !important;
        }
        .table tbody td {
            vertical-align: middle !important;
        }
        ._input {

        }
        ._input input {

        }
        .search_name {
            border: solid 1px #ccc;
            padding: 4px 4px 4px 8px;
            margin-right: 5px;
            border-radius: 4px;
        }
        .btn-primary {
            color: #fff;
            background-color: #337ab7;
            border-color: #2e6da4;
        }
        .btn-primary:hover {
            color: #fff;
            background-color: #286090;
            border-color: #204d74;
        }
        .btn-info {
            color: #fff;
            background-color: #5bc0de;
            border-color: #46b8da;
        }
        .btn-info:hover {
            color: #fff;
            background-color: #39b3d7;
            border-color: #269abc;
        }
        .btn-warning {
            color: #fff;
            background-color: #f0ad4e;
            border-color: #eea236;
        }
        .btn-warning:hover {
            color: #fff;
            background-color: #ec971f;
            border-color: #d58512;
        }
        .btn-danger {
            color: #fff;
            background-color: #d9534f;
            border-color: #d43f3a;
        }
        .btn-danger:hover {
            color: #fff;
            background-color: #c9302c;
            border-color: #ac2925;
        }
    </style>
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>职员表</h2>
    </div>
    <div class="data" style="display: none;">
        <select id="data-nickname" name="li[username]">
            <volist name="member" id="vo">
                <option value='{$vo.nickname}'>{$vo.nickname}</option>
            </volist>
        </select>
    </div>
    <div class="dataname" style="display: none;">
        <select id="data-name" name="li[name]">
            <volist name="category" id="vo">
                <option value='{$vo.name}'>{$vo.name}</option>
            </volist>
        </select>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <div class="fl">
                <button   class="add btn btn-default c_green">新 增</button>
                <button class="btn btn-default ajax-post" url="{:U('changeStatus',array('method'=>'resumeUser'))}" target-form="ids">启 用</button>
                <button class="btn btn-default ajax-post" url="{:U('changeStatus',array('method'=>'forbidUser'))}" target-form="ids">禁 用</button>
                <button class="btn btn-default ajax-post confirm" url="{:U('changeStatus',array('method'=>'deleteUser'))}" target-form="ids">删 除</button>
            </div>
        </div><!-- /.panel-heading -->

        <div class="panel-body topa" >
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover" id="dataTables-user"><!-- 必须设定表格的id == -->
                    <thead>
                    <tr>
                        <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                        <th class="">UID</th>
                        <th class="">用户名</th>
                        <th class="">创建时间</th> 
                        <th class="">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <volist name="_list" id="vo">
                        <tr>
                            <td><input class="ids" type="checkbox" name="id[]" value="{$vo.uid}" /></td>
                            <td>{$vo.uid} </td>
                            <td>{$vo.nickname}</td>
                            <td>{$vo.create_time|date="Y-m-d",###}</td> 
                            <td><eq name="vo.status" value="1">
                                <a href="{:U('changeStatus?method=forbidUser&id='.$vo['uid'])}" class="ajax-get">禁用</a>
                                <else/>
                                <a href="{:U('changeStatus?method=resumeUser&id='.$vo['uid'])}" class="ajax-get">启用</a>
                            </eq>
                                <a href="{:U('AuthManager/group?uid='.$vo['uid'])}" class="authorize">授权</a>
                                <a href="{:U('/changeStatus?method=deleteUser&id='.$vo['uid'])}" class="confirm ajax-get">删除</a>
                            </td>
                        </tr>
                    </volist>
                    </tbody>
                </table>
            </div><!-- /.table-responsive -->
            <!-- /.row (nested) -->
        </div><!-- /.panel-body -->
    </div><!-- /.panel -->
    <style>
        .topa{
            position: relative;
        }
        .newly{
            width: 600px;
            height: 500px;
            position: absolute;
            top: 20%;
            left: 50%;
            margin-left: -300px;
        }
        .add_record { text-align: center; }
        .add_record > div { display: inline-block; margin-top: 38px; }
        .add_record ul { margin: 0; }
        .add_record ul li {  }
        .add_record ul li span { float: left; }
        .add_record ul li input { float: left; }
    </style>

    <!-- 分页 -->
    <div class="page">
        {$_page}
    </div>
    </div><!-- /.panel -->
</block>
<block name="script">
    <link rel="stylesheet" href="__STATIC__/datetimepicker/css/datetimepicker.css" />
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
    <script src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
    <script type="text/javascript" src="__JS__/jquery.table2excel.min.js"></script>


    <script type="text/javascript">
        $('#goback').on('click',function () {
            $('#addshow').hide();
        })
        // 新增供应商
        var _htms =
                "<form id='_form' name='myform' method='post' role='form'>"+
                "<div class='add_record'>"+
                "<div>"+
                "<ul>"+
                "<li class='c_f'>"+
                "<span>用户名</span>"+
                "<input type='text' class='form-control' name='username' value=''>"+
                "</li>"+
                "<li class='c_f'>"+
                "<span>密码</span>"+
                "<input type='password' class='text input-large form-control' name='password' value=''> "+
                "</li>"+
                "<li class='c_f'>"+
                "<span>密码</span>"+
                "<input type='password' class='text input-large form-control' name='repassword' value=''> "+
                "</li>"+
                "<li class='c_f'>"+
                "<span>邮箱</span>"+
                "<input type='text' class='text input-large form-control' name='email' value=''> "+
                "</li>"+
                "<p>"+
                "<button class='submit btn btn-default c_green'  >确 定</button>"+
                "</p>"+
                "</ul>"+
                "</div>"+
                "</div>"+
                "</form>";
        $('.add').click(function(){
            //新增记录层
            layer.open({
                title: '新增职员',
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area: ['500px', '700px'], //宽高
                content: _htms
            });
        });
        var boole = true;
        $(document).on('click','.submit',function(){
            $('.add_record ul li').each(function(){
                var input = $(this).find('input').val();
                if(input == ''){
                    boole = false;
                    layer.msg('请填写完整内容!');
                    return false;
                }else{
                    boole = true;
                }
            });
            if(boole){
                var info = $('#_form').serialize();
                $.ajax({
                    type:"post",
                    url:"__URL__/add",
                    data:info,
                    async:true,
                    success:function(data){
                        var info = data;
                        if (info == '密码和重复密码不一致!') {
                            alert('密码和重复密码不一致!');
                            return;
                        }
                        else if (info == '用户名被占用！') {
                            alert('用户名被占用！');
                            return;
                        }
                        else if (info == '用户名长度必须在16个字符以内！') {
                            alert('用户名长度必须在16个字符以内！');
                            return;
                        }
                        else if (info == '用户名被禁止注册！') {
                            alert('用户名被禁止注册！');
                            return;
                        }
                        else if (info == '密码长度必须在6-30个字符之间！') {
                            alert('密码长度必须在6-30个字符之间！');
                            return;
                        }
                        else if (info == '邮箱格式不正确！') {
                            alert('邮箱格式不正确！');
                            return;
                        }
                        else if (info == '邮箱被占用！') {
                            alert('邮箱被占用！');
                            return;
                        }
                        else if (info == '未知错误') {
                            alert('未知错误');
                            return;
                        }
                        else if (info == '邮箱长度必须在1-32个字符之间！') {
                            alert('邮箱长度必须在1-32个字符之间！');
                            return;
                        }
                        else if (info == '用户添加成功!') {
                            window.location.reload();
                        }
                    }
                });
            }
            return false;
        });
    </script>

</block>
